package com.le.ssm.service.impl;

import com.le.ssm.core.exception.LoginException;
import com.le.ssm.mapper.AddressMapper;
import com.le.ssm.model.Address;
import com.le.ssm.service.AddressService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
@AllArgsConstructor
public class AddressServiceImpl implements AddressService {
    public AddressMapper addressMapper;

    @Override
    public List<Address> list(Address address) {
        return addressMapper.list(address);
    }

    @Override
    public Address login(String name, int phone) throws LoginException {
        Address user=addressMapper.selectByName(name);
        if(user==null){
            throw new LoginException("不存在");
        }
        if(phone!=user.getPhone()){
            throw new LoginException("手机错了");
        }
        return user;
    }



}
